/**
 * 
 */
package edu.wpi.cs509.messages.server;


import java.util.List;

import edu.wpi.cs509.messages.client.MsgLoginReply;
import edu.wpi.cs509.network.Connection;
import edu.wpi.cs509.representation.ActionBaseClass;
import edu.wpi.cs509.representation.ClientGame;
import edu.wpi.cs509.representation.GameListItem;
import edu.wpi.cs509.representation.GameID;
import edu.wpi.cs509.representation.UserName;
import edu.wpi.cs509.representation.UserPair;
import edu.wpi.cs509.representation.UserStatistics;

/**
 * This interface defines the methods needed by messages
 * executed on the server (sent by the client).
 * @author sparadis, based on the ClientLogicRequest 
 * and other interfaces by afoltan, and also from discussion
 * brd and emails.
 *
 */
public interface MsgServerUserIntfc {

	
	/**
	 * Starts a user session by logging the user into the Stratego server
	 * @param pair - username/password to log in.
	 * @return - the result of the login (good/invalid)
	 */
	MsgLoginReply.LoginResult login(UserPair pair);
	
	/**
	 * Ends a user session by logging the user out of the Stratego server
	 */
	void logout(Connection conn);

	/**
	 * Retrieves the leaderboard information for the top players.
	 * @param rank - the starting rank position to return
	 * @param count - the number of player stats to return following rank (inclusive).
	 * @param conn - the connection from this message
	 */
	List<UserStatistics> getLeaderBoard(int rank, int count, Connection conn);
	
	/**
	 * Retrieves the leaderboard information for the named players.
	 * @param username - the name of the player to start from 
	 * @param count - the number of player stats to return following rank (inclusive).
	 * @param conn - the connection from this message
	 */
	List<UserStatistics> getLeaderBoard(UserName username, int count, Connection conn);
	
	/**
	 * Retrieves the stats for the named player.
	 * @param username - the name of the player for whom the stats will be retrieved.
	 * @param conn - the connection from this message
	 */
	UserStatistics getPersonalStats(UserName username, Connection conn);
	
	/**
	 * Retrieves a list of joinable games from the server. These games have only
	 * one player.
	 */
	List<GameListItem> getJoinableGames();
	
	/**
	 * Retrieves a list of observable games from the server.  These games have two
	 * players that have finalized their initial piece placement.
	 */
	List<GameListItem> getObservableGames();
	
	/**
	 * Starts a new game on the server and makes the caller player 1.
	 */
	ClientGame startNewGame(Connection playerOne);
	
	/**
	 * Join the specified game.
	 * @param gId - id of game to join.
	 * @param user - A connection object corresponding to the user.
	 * @return true if join was successful
	 */
	ClientGame joinGame(GameID gId, Connection conn);
	
	/**
	 * Leave the specified game.
	 * @param gId - id of game to join.
	 * @param conn - A connection object corresponding to the user.
	 * @return true if leave was successful, false otherwise
	 */
	boolean leaveGame(GameID gId, Connection conn);
	
	/**
	 * Observe the specified game.
	 * @param gId - id of game to observe
	 * @param conn - A connection object corresponding to the user.
	 * @return true if observe was successful
	 */
	ClientGame observeGame(GameID gId, Connection conn);
	
	/**
	 * Stop observing the specified game.
	 * @param gId - id of game to stop observing
	 * @param conn - A connection object corresponding to the user.
	 * @return true if observer was removed successfully
	 */
	boolean stopObservingGame(GameID gId, Connection conn);
	
	/**
	 * Player has placed all pieces and is ready to start the game.
	 * @param gId - id of game to start playing
	 * @param conn - A connection object corresponding to the user.
	 * @return true if the request succeeded 
	 */
	boolean playerReady(GameID gId, Connection conn);
	
	/**
	 * This message contains a request to move a single piece.
	 * @param gId - id of game for piece to be moved
	 * @param moveAction - the request move
	 */
	void movePiece(GameID gId, ActionBaseClass moveAction, Connection conn);
	
}


